<?php
namespace backend\models;

use Yii;
use yii\base\Model;
use yii\base\Exception;
use common\models\CustomerOrder;
use common\models\OrderProduct;
use common\models\TransferUndertake;
use common\models\Employees;
use common\models\Process;
use common\models\User;
use common\models\Department;
use common\models\Customer;
use common\models\Product;

class ViewTask extends Model
{
	public $transfer;
	public $undertake;
	public $customer;
	public $product;
	public $check_time;
	public $out_storage_time;
	public $send_code;
	public $send_time;
	public $delivery_code;
	public $sign_time;


	public function __construct($id=null, $config = [])
	{
		$transfer_undertake = TransferUndertake::findOne($id);
		$this->transfer = Employees::findOne($transfer_undertake->transfer)->realname;
		$this->undertake = Employees::findOne($transfer_undertake->undertake)->realname;
		$this->customer = Customer::findOne(CustomerOrder::find()->where(['order' => $transfer_undertake->oid])->one()->cid)->username;
		$this->product = Product::findOne(OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->pid)->name;
		$this->check_time = OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->check_time ? date('Y-m-d',OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->check_time): '';
		$this->out_storage_time = OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->out_storage_time ? date('Y-m-d',OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->out_storage_time): '';
		$this->send_code = OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->send_code;
		$this->send_time = OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->send_time ? date('Y-m-d',OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->send_time): '';
		$this->delivery_code = OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->delivery_code;
		$this->sign_time = OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->sign_time ? date('Y-m-d',OrderProduct::find()->where(['oid' => $transfer_undertake->oid])->one()->sign_time): '';


		return parent::__construct($config);
	}

	public function formName()
    {
        return '';
    }




}	